{\rtf1\ansi\ansicpg1252\deff0\deflang1053{\fonttbl{\f0\fnil\fcharset0 Arial;}{\f1\fswiss\fcharset0 Arial;}}
{\colortbl ;\red0\green0\blue0;\red160\green80\blue208;\red255\green0\blue128;\red0\green128\blue0;\red64\green160\blue208;}
{\*\generator Msftedit 5.41.15.1515;}\viewkind4\uc1\pard\fs20 
#ABOUT
Custom Command allows you to use your own custom
commands in your HotBasic source code just as if they were
native HotBasic commands, it can also be used for Custom Objects 
so they become native objects. It's using the Hotbasic Optimizer technology.
All \b Custom Commands\cf0\f1 is in the sourcecode case unsensitive.

Please contribute so the command list can increase and HotBasic get 
more smart functions
Send your functions/objects that you think should be included with the
source in a .inc file and a .txt file that describes the function to
fredrik at fnoware.se

#end

#STRLEFT
Gives you the string that is left of the searched string. The search for the
string is from left to right in the source string.

==========
Syntax
==========
STRLEFT(source as string,Searchstring as string) as string

==========
Example
==========
$apptype console
defstr tmp,tmp2
tmp="My name is Fredrik"
tmp2=strleft(tmp," is ")
print tmp2
pause

===========
Result
===========
<My name>

#end

#STRRIGHT
Gives you the string that is right of the searched string. The search for the
string is from left to right in the source string.

==========
Syntax
==========
STRRIGHT(source as string,Searchstring as string) as string

==========
Example
==========
$apptype console
defstr tmp,tmp2
tmp="My name is Fredrik"
tmp2=strright(tmp," is ")
print tmp2
pause

===========
Result
===========
Fredrik

#end
#STRLEFTBACK
Gives you the string that is left of the searched string. The search for the
string is from right to left in the source string.
==========
Syntax
==========
STRLEFTBACK(source as string,Searchstring as string) as string

==========
Example
==========
$apptype console
defstr tmp,tmp2
tmp="c:\hotbasic\project\customcommand\customcommand.txt"
tmp2=strleftback(tmp,"\")
print tmp2
pause

===========
Result
===========
'Prints the Path
c:\hotbasic\project\customcommand

#end
#STRRIGHTBACK
Gives you the string that is right of the searched string. The search for the
string is from right to left in the source string.

==========
Syntax
==========
STRRIGHTBACK(source as string,Searchstring as string) as string

==========
Example
==========
$apptype console
defstr tmp,tmp2
tmp="c:\hotbasic\project\customcommand\customcommand.txt"
tmp2=strleftback(tmp,"\")
print tmp2
pause

===========
Result
===========
'Prints the filename
customcommand.txt

#end
#STROEM
Converts a string to OEM format so that all characters display correctly in a 
commandprompt like Swedish or other special letters.

==========
Syntax
==========
STROEM(Stringtoconvert as string) as string

==========
Example
==========
$apptype console
defstr tmp,tmp2
tmp="I write some text but This does not have special letters, but other can"
tmp2=stroem(tmp)
print tmp2
pause

===========
Result
===========
I write some text but This does not have special letters, but other can

#end
#GETFILESINFOLDER
Get all files or files of a certain type in specified folder

==========
Syntax
==========
GETFILESINFOLDER(DirFolder$ As String, DirFileExtension$ As String) As String

==========
Example
==========
$apptype console
defstr mylist$
mylist$=GetFilesInFolder("C:\","txt")
'All PDF Files In C:\
print mylist$
mylist$=GetFilesInFolder("C:\","")
'All Files In C:\
print mylist$
pause
#end
#DAYSINMONTH
returns numbers of days per month for the specified year.

==========
Syntax
==========
DAYSINMONTH($iYear as integer,$iMonth as integer) as integer

==========
Example
==========
$apptype console
print daysinmonth(2009,08);" days"
pause

==========
Result
==========
31 days

#end
#RINSTR
Reverse instr returns index of search string (rin$) ELSE 0
Note that you will get the position where the string ends not begins


==========
Syntax
==========
FUNCTION RINSTR(rin AS LONG, my$ AS STRING, rin$ AS STRING) AS LONG

==========
Example
==========
$apptype console
defstr tmp
deflng pos
tmp="The sun is yellow and the ground is brown"
pos=rinst(tmp,"is")
print pos
pause

==========
Result
==========

 35
#end
#DATEISLEAPYEAR

Function DateIsLeapYear($iYear as integer) as integer
'===============================================================================
'
' Description:      Returns 1 if the specified year falls on a leap year and
'                   returns 0 if it does not.
' Parameter(s):     $iYear - Year to check  yyyy
' Requirement(s):   None
' Return Value(s):  On Success - 0 = Year is not a leap year
'                                1 = Year is a leap year
'                   On Failure - 0 
' Author(s):        Jeremy Landes <jlandes at landeserve dot com>
'                   Converted To HB by C. de Visser
' Note(s):          None
'
'===============================================================================

#end
#FILESTAMP

' Description: 
'sFileName must be with double slashes in the filename, easyiest way to fix this is to do a
'sFileName=ReplaceSubstr$(sfileName,"\","\\")
'ChangeDate can be 
	1 for changing creationdate
	2 for Last Access Date
	3 for Last Write Time

Function FILESTAMP(ByVal sFileName As String, byval ChangeDate as integer,ByVal intDate as Int64) As integer

#end
#FORMAT 
Format a floating number to specified number of decimals

==========
Syntax
==========
FUNCTION FORMAT (fX as DOUBLE, fStr As STRING) As STRING

==========
Example
==========
'Usage: MyStr = Format(MyFloat,fStr)
'Example: MyStr = Format(x,"####.##")


#end
#HEXINT64
Easy handling of Date objects
Load INT64 and save them as HEX Strings
Load Hex Strings and save them as INT64

==========
Syntax
==========
Object.LOADINT64
object.SAVEINT64
object.SAVEHEX
object.LOADHEX

==========
Example
==========
$apptype console
Dim HI as HEXINT64
Dim I as INT64
Dim d as Date
dim t as string
d.update
d.SaveInt64 I

HI.loadINT64(I)
t=HI.SaveHex
print t
pause

#end
#SORTLIST
Sorts a List object in

==========
Syntax
==========
FUNCTION SORTLIST(MYLIST as List) AS LIST

==========
Example
==========
$apptype console
dim MyList as list
MyList.additems "Stockholm","London","Madris","New York","Paris"
Print "Original List"
Print MyList
MyList = SortList(MyList)
Print " "
print "Sorted List"
print MyList 
pause

==========
Result
==========
Original List
Stockholm
London
Madris
New York
Paris

Sorted List
London
Madris
New York
Paris
Stockholm


#end
#LOADIMAGE
Load and image of jpg/gif/png/bmp into a Hotbasic Bitmap object
==========
Syntax
==========
FUNCTION LOADIMAGE(LOADIMAGE_FileEx as string,LOADIMAGE_RetBitmap as long) as integer 

==========
Example
==========
dim t as Bitmap,x as integer
x=LOADIMAGE("c:\temp\Circles.jpg",@t)
create Form1 As FORM
OnPaint = Form1Paint
end create
Form1.showmodal

end
Form1Paint:
Form1.Draw (0, 0, t)
return

==========
Result
==========
the image is loaded and converted to a bmp

#end
#COPYTOCLIPBOARDBMP
Copy a Hotbasic Bitmap object into the clipboard
==========
Syntax
==========
SUB COPYTOCLIPBOARDBMP(BMP_hdl as long)

==========
Example
==========
dim t as Bitmap,x as integer
x=LOADIMAGE("c:\users\fno\hb\project\gdi_plus\Circles.jpg",@t)
create Form1 As FORM
OnPaint = Form1Paint 
create b as button 
onclick="copytoclip"
end create
end create 

Form1.showmodal

end 
copytoclip: 
copytoclipboardbmp(@t)
return
loadagin:
return
Form1Paint:
Form1.Draw (0, 0, t)
return


==========
Result
==========
The Bitmap image is placed into the clipboard

#end
#COPYFROMCLIPBOARDBMP
Copy a Hotbasic Bitmap object from the clipboard
==========
Syntax
==========
sub COPYFROMCLIPBOARDBMP(BMP_hdl as long)

==========
Example
==========
dim t as Bitmap,x as integer
create Form1 As FORM
OnPaint = Form1Paint 
create b as button 
caption="copy image"
onclick="copyfromclip"
end create
end create 

Form1.showmodal

end 
copyfromclip: 
CopyFromClipBoardBMP(@t)
Form1.repaint
return
loadagin:
return
Form1Paint:
Form1.Draw (0, 50, t)
return

==========
Result
==========
The Bitmap image is copied from the clipboard
#end
